<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="en">
  <head>
    <base href="<%=basePath%>">
    
    <title>小秘书</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" id="viewport" />
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<link rel="stylesheet" type="text/css" href="css/secretary.css">
	<style type="text/css">
	.opacity{
        -webkit-animation: opacity 0.3s linear;
        animation: opacity 0.3s linear;
    @-webkit-keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }
    @keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }
}
    </style>
    <link rel="stylesheet" href=" dist/dropload.css">
	<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
  </head>
  
  <body>
  	<input class="userid" value="${userId}" type="hidden">
    <section class="sec">
		<div class="sec-div">
			<ul class="lists">
			</ul>
		</div>
	</section>
	<script src="dist/dropload.min.js"></script>
<script>
$(function(){
	var userToken='${userId}';
    // 页数
    var page = 0;
    // 每页展示10个
    var size = 10;

    // dropload
    $('.sec-div').dropload({
        scrollArea : window,
        domUp : {
            domClass   : 'dropload-up',
            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
        },
        domDown : {
            domClass   : 'dropload-down',
            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData  : '<div class="dropload-noData">暂无数据 </div>'
        },
        loadUpFn : function(me){
     	 var reqjson = {
           		"userId":userToken,
            	"pageNow":1,
            	"pageSize":size
            };
            $.ajax({
                	type : "POST",
					contentType: "application/json; charset=utf-8",
					dataType : "json",
					url : "<%=path %>/getMytipSms",
					data: JSON.stringify(reqjson),
					success : function(infoMap) {
                    var result = '<ul>';
                 	 $.each(infoMap.Mytipall,function(i,n){
										result+='<li class="opacity" >'
	                        				+'<p >'+n.sendTime+'</p>'
	                        				+'<div class="sec-cion"></div>'
	                        				+'<div class="sec-cont">'+'<div class="sec-word" >'+n.smsContent+'</div>';
	                        				if(n.smsType==201){
	                        					result +='<h6 onclick="mcc(\'appendInfo\')">完善注册</h6>';
	                        				}
	                        				else if(n.smsType==202){
	                        					result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				else if(n.smsType==203){
	                        					result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				else if(n.smsType==204){
	                        					result +='<h6 onclick="mcc(\'appHomeIndex\')">首页</h6>';
	                        				}
	                        				else if(n.smsType==205){
	                        					result +='<h6 onclick="mcc(\'squareInfoList?id='+n.paramId+'\')">他人广场</h6>';
	                        				}
	                        				else if(n.smsType==206){
	                        					result +='<h6 onclick="mcc(\'taskInfo?id='+n.paramId+'\')">任务详情</h6>';
	                        				}
	                        				else if(n.smsType==207){
	                        					result +='<h6 onclick="mcc(\'otherUserInfo?id='+n.paramId+'\')">他人相册</h6>';
	                        				}
	                        				else if(n.smsType==208){
	                        					result +='<h6 onclick="mcc(\'myFans\')">每日首次登录</h6>';
	                        				}
	                        				else if(n.smsType==209 || n.smsType==211 || n.smsType==212){
	                        					result +='<h6 onclick="mcc(\'activityInfo?id='+n.paramId+'\')">活动详情</h6>';
	                        				}else if(n.smsType==210){
	                        					result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				result +='</div>'; 
	                                    +'</li></ul>';
								});
                    // 为了测试，延迟1秒加载
                    setTimeout(function(){
                        $('.lists').html(result);
                        // 每次数据加载完，必须重置
                        me.resetload();
                        // 重置页数，重新获取loadDownFn的数据
                        page = 1;
                        // 解锁loadDownFn里锁定的情况
                        me.unlock();
                        me.noData(false);
                    },1000);
                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                }
            });
        },
        loadDownFn : function(me){
            var result = '<ul>';
            page++;
            var reqjson = {
           		"userId":userToken,
            	"pageNow":page,
            	"pageSize":size
            	};
            $.ajax({
               		type : "POST",
					contentType: "application/json; charset=utf-8",
					dataType : "json",
					url : "/pnservice/getMytipSms",
					data: JSON.stringify(reqjson),
					success : function(infoMap) {
                	var Mytipall= infoMap.Mytipall;
                    if(Mytipall.length > 0){
                     	$.each(Mytipall,function(i,n){
										result+='<li class="opacity" >'
	                        				+'<p >'+n.sendTime+'</p>'
	                        				+'<div class="sec-cion"></div>'
	                        				+'<div class="sec-cont">'+'<div class="sec-word" >'+n.smsContent+'</div>';
	                        				if(n.smsType==201){
	                        				result +='<h6 onclick="mcc(\'appendInfo\')">完善注册</h6>'; 
	                        				}
	                        				else if(n.smsType==202){
	                        				result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				else if(n.smsType==203){
	                        				result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				else if(n.smsType==204){
	                        				result +='<h6 onclick="mcc(\'appHomeIndex\')">首页</h6>';
	                        				}
	                        				else if(n.smsType==205){
	                        				result +='<h6 onclick="mcc(\'squareInfoList?id='+n.paramId+'\')">他人广场</h6>';
	                        				}
	                        				else if(n.smsType==206){
	                        				result +='<h6 onclick="mcc(\'taskInfo?id='+n.paramId+'\')">任务详情</h6>';
	                        				}
	                        				else if(n.smsType==207){
	                        				result +='<h6 onclick="mcc(\'otherUserInfo?id='+n.paramId+'\')">他人相册</h6>';
	                        				}
	                        				else if(n.smsType==208){
	                        				result +='<h6 onclick="mcc(\'myFans\')">每日首次登录</h6>';
	                        				}
	                        				else if(n.smsType==209 || n.smsType==211 || n.smsType==212){
	                        				result +='<h6 onclick="mcc(\'activityInfo?id='+n.paramId+'\')">活动详情</h6>';
	                        				}
	                        				else if(n.smsType==210){
	                        				result +='<h6 onclick="mcc(\'myUserInfo\')">我的空间</h6>';
	                        				}
	                        				result +='</div>'; 
	                                    +'</li></ul>';
									});
                    	}else{
                        // 锁定
                        me.lock();
                        // 无数据
                        me.noData();
                    }
                    // 为了测试，延迟1秒加载
                    setTimeout(function(){
                        // 插入数据到页面，放到最后面
                        $('.lists').append(result);
                        // 每次数据插入，必须重置
                        me.resetload();
                    },1000);
                },
                error: function(xhr, type){
                    //alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                }
            });
        },
        threshold : 50
    });

});

function mcc(url){
	location.href=url;
}
</script>
  </body>
</html>
